/*
 * Metaverse Core
 * Copyright (C) 2010 Vyacheslav Vorobyov, All rights reserved.
 * See LICENSE for full license information.
 */
package org.metaverse.warehouse;


import org.metaverse.warehouse.com.Constraint;
import org.metaverse.warehouse.Senary.Slot;
import org.openrdf.model.ValueFactory;
import org.singularity.io.CloseableIterator;

/**
 * This is a service interface to allow user to fetch 
 * statements (senaries if to be exact) using constraint.
 * 
 * @author vjache
 *
 */
public interface Fetcher {
	
	ValueFactory getValueFactory();
	/**
	 * Fetches statements under given constraint and orders them if necessary.
	 * @param aConstraint - a constraint
	 * @param aGroupBy - a grouping specification
	 * @return - an input stream of statements 
	 */
	CloseableIterator<Senary> fetch(Constraint aConstraint, Slot... aGroupBy) throws WarehouseException;
	<T extends FetchProcedure> T fetch(FetchProcedure aProcedure) throws Exception;
	/**
	 * Counts statements under given constraint.
	 * @param aConstraint - a constraint
	 * @return - a number of satisfying statements
	 */
	int count(Constraint aConstraint) throws WarehouseException;
}
